package jee.boot.entity.auth;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import jee.boot.common.annotation.Table;
import jee.boot.common.annotation.Transient;
import jee.boot.common.basic.interceptor.impl.DefaultPreInsertInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreQueryInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreUpdateInterceptor;
import jee.boot.entity.system.GeneralDataEntity;

import java.util.List;
import java.util.Map;

/**
 * 原子权限
 */
@Table(name = "at_authority")
public class Authority extends GeneralDataEntity<Authority> {

    private static final long serialVersionUID = 1L;

    /**
     * 原子权限状态
     */
    @jee.boot.common.annotation.Column(name = "st_authority_status")
    private String authorityStatus;//字典：DIC_AUTH_AuthorityStatus

    /**
     * * DIC_AUTH_CtrledEntityType_CET01	资源
     * * DIC_AUTH_CtrledEntityType_CET03	树节点集
     * * DIC_AUTH_CtrledEntityType_CET04	Model
     * * DIC_AUTH_CtrledEntityType_CET05	Column
     * * DIC_AUTH_CtrledEntityType_CET06	RowSet
     * * DIC_AUTH_CtrledEntityType_CET07	CellSet
     */
	/**
	 * 资源列表
	 */
	@Transient
    private List<AuthEntity> resourceList= Lists.newArrayList();
	/**
	 *树节点列表
	 */
    @Transient
    private List<AuthEntity> treeNodeList= Lists.newArrayList();
	/**
	 *Model列表
	 */
    @Transient
    private List<AuthEntity> modelList= Lists.newArrayList();
	/**
	 *Column列表
	 */
    @Transient
    private List<AuthEntity> columnList= Lists.newArrayList();
	/**
	 *RowSet列表
	 */
    @Transient
    private List<AuthEntity> rowSetList= Lists.newArrayList();
	/**
	 *CellSet列表
	 */
    @Transient
    private List<AuthEntity> cellSetList= Lists.newArrayList();
	/**
	 * 原子权限内,按path进行统计所有的请求(相同请求按优先级大的取)
	 * <url,Request>
	 */
	@Transient
	private Map<String,AuthEntity> requestMap=Maps.newHashMap();
	/**
	 * 原子权限内的所有角色
	 */
	@Transient
	private List<Role> roleList=Lists.newArrayList();

	//------------冗余数据,给前端分片查询model下的column时候使用的
	@Transient
	private ModelData modelData;
	@Transient
	private RowSet rowSet;


	public Authority() {
		super();
	}
    public Authority(String id) {
        super(id);
    }

	public String getAuthorityStatus() {
		return authorityStatus;
	}

	public void setAuthorityStatus(String authorityStatus) {
		this.authorityStatus = authorityStatus;
	}

	public List<AuthEntity> getResourceList() {
		return resourceList;
	}

	public void setResourceList(List<AuthEntity> resourceList) {
		this.resourceList = resourceList;
	}

	public List<AuthEntity> getTreeNodeList() {
		return treeNodeList;
	}

	public void setTreeNodeList(List<AuthEntity> treeNodeList) {
		this.treeNodeList = treeNodeList;
	}

	public List<AuthEntity> getModelList() {
		return modelList;
	}

	public void setModelList(List<AuthEntity> modelList) {
		this.modelList = modelList;
	}

	public List<AuthEntity> getColumnList() {
		return columnList;
	}

	public void setColumnList(List<AuthEntity> columnList) {
		this.columnList = columnList;
	}

	public List<AuthEntity> getRowSetList() {
		return rowSetList;
	}

	public void setRowSetList(List<AuthEntity> rowSetList) {
		this.rowSetList = rowSetList;
	}

	public List<AuthEntity> getCellSetList() {
		return cellSetList;
	}

	public void setCellSetList(List<AuthEntity> cellSetList) {
		this.cellSetList = cellSetList;
	}

	public Map<String, AuthEntity> getRequestMap() {
		return requestMap;
	}

	public void setRequestMap(Map<String, AuthEntity> requestMap) {
		this.requestMap = requestMap;
	}

	public ModelData getModelData() {
		return modelData;
	}

	public void setModelData(ModelData modelData) {
		this.modelData = modelData;
	}

	public RowSet getRowSet() {
		return rowSet;
	}

	public void setRowSet(RowSet rowSet) {
		this.rowSet = rowSet;
	}

	public List<Role> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}

	@Override
	public void preInsert() {
		new DefaultPreInsertInterceptor().execute(this);
	}
	@Override
	public void preUpdate() {
		new DefaultPreUpdateInterceptor().execute(this);
	}
	@Override
	public void preQuery() {
		new DefaultPreQueryInterceptor().execute(this);
	}
}
